/**
 * Created by Jay on 2016/6/15.
 */
function answer_question_list(){
    $("body").off();

    //详情
    $("body").on("click",".detail_list",function(e){
       console.log(e.target.dataset.id);
       mccmsa.goTo("answer_question_list_detail","answer_question_list_detail",{'this_id':e.target.dataset.id});
    });

    $("body").on("click",".push_delete",function(){
        var id=$(this).attr("data-id");
        delete_tips({
            url:"messageController/delReciveQuestion?id="+id,
            method:"get",
            content:"确认要删除？",
            data:{pageSize: 10, pageNo: 1},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    });

    /*查看S*/
    $("body").on("click",".check_tip",function(e){
         mccmsa.goTo("check_sub_card","check_sub_card",{'this_id':e.target.dataset.id})
    });

    /*查看E*/
    /*头部的checkbox S*/
    /*单个 删除S*/
    $("body").on("click",".push_delete",function(){
        var id=$(this).attr("data-id");
        console.log("id_+_single==="+id);
        delete_tips({
            url:"questionAnswerManageController/deleteQa",
            method:"POST",
            content:"确认要删除？",
            data:{'idStr':id},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    });

    /*单个删除 E*/
    /*批量删除 S*/
    var judge_check=0;
    $("#del_all").on('click',function(){
        console.log("dededeedeedededededeedededededed");
        var del_list="";
        for(var i=1;i<$("input[type='checkbox']").length;i++){
            if($("input[type='checkbox']").eq(i).prop("checked")==true){
                judge_check=1;
                del_list+=$("input[type='checkbox']").eq(i).attr("data-id")+",";
            }
        }
        console.log("del_list_not_single"+del_list)
        if(judge_check==0){
            layer.alert("请选择需要删除的消息");
            return
        }
        console.log("del_list_+_+_+_+_+"+del_list);
        delete_tips({
            url:"questionAnswerManageController/deleteQa",
            method:"POST",
            content:"确认要批量删除？",
            data:{idStr:del_list},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    })
    /*批量删除 E*/

    /* checkbox first 批量选择 S*/
    function click_all_change(){
        /*checkbox all s*/
        var check_all=1;
        $("#check_all").on("click",function() {
            var check=this.getAttribute("checked");
            if(!$("#check_all").prop("checked")){//如果 第一个checkbox 是已经点了的
                for(var i=0;i<$("input[type='checkbox']").length;i++){
                    $("input[type='checkbox']").eq(i).prop("checked",false)
                }
                return;
            }
            for(var i=0;i<$("input[type='checkbox']").length;i++){
                $("input[type='checkbox']").eq(i).prop("checked", true);
            }
        })
        /*checkbox all  E*/
    }
  /*check first 批量选择 E*/
    click_all_change();
    /*头部的checkbox E*/
    var first_or_not=1;
    var clickChange_aq=1;

    /*批量删除 S*/
    var judge_check=0;
    $("#del_all").on('click',function(){
        console.log("dededeedeedededededeedededededed");
        var del_list="";
        for(var i=1;i<$("input[type='checkbox']").length;i++){
            if($("input[type='checkbox']").eq(i).prop("checked")==true){
                judge_check=1;
                del_list+=$("input[type='checkbox']").eq(i).attr("data-id")+",";
            }
        }
        if(judge_check==0){
            layer.alert("请选择需要删除的消息");
            return
        }
        console.log("del_list_+_+_+_+_+"+del_list);
        delete_tips({
            url:opt.url,
            method:"POST",
            content:"确认要批量删除？",
            data:{ids:del_list},
            alert:"删除成功",
            alert_error:"删除失败"
        })
    })
    /*批量删除 E*/


    $("body").on("click",".change_show",function(){
        page_i=0;
        //console.log("click2");
        var this_is=$(this).attr("data-this-id");
        var status=$(this).attr("data-status");
        if(status==0){
            status=1;
         }else{
            status=0;
        }
        mccmsa.ajax({
            url: "questionAnswerManageController/showOrHide",
            method: "get",
            data: {questionAnswerId:this_is, isShow:status},
            success: function (data){
                if(clickChange_aq==1){
                    /*搜全部*/
                    $.ajax({
                            url: "questionAnswerManageController/showAllQuestion",
                            method:"get",
                            data: {pageSize: 10, pageNo: sessionStorage.getItem("this_page_click_num")}
                        })
                        .done(function(data){
                            set_seqsum(
                                {
                                    pageNo:data.result.pageNo,
                                    pageSize:data.result.pageSize
                                }
                            );//设置这一页的pageNO 和pageSize
                            if(first_or_not==1){
                                create_page({
                                    url:"questionAnswerManageController/showAllQuestion",
                                    temp:"getColumnTableData_a_q_l",
                                    contain:"#ColumnTableData_comment_a_q_l",
                                    data:data,
                                    method:"get",
                                    add_data:{content:$(".rep_search_real_s").val(),isShow:$("#select_d_p").val()},
                                    prePageSize:data.result.pageSize,
                                    prepageNo:data.result.pageNo
                                })//生成分页
                                first_or_not=2;
                            }
                            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                                templateId: "getColumnTableData_a_q_l",
                                container: $("#ColumnTableData_comment_a_q_l"),
                                data: data,
                                callback:function(){
                                    click_all_change();
                                }
                            })
                        })
                        .fail(function(){
                            console.log("fail");
                        })
                }
                else if(clickChange_aq==2){
                  /*搜其他*/
                    $.ajax({
                            url: "questionAnswerManageController/searchQuestion",
                            method: "post",
                            data: {pageSize: 10, pageNo:sessionStorage.getItem("this_page_click_num"),content:$(".rep_search_real_s").val(),isShow:$("#select_d_p").val()}
                        })
                        .done(function(data){
                            //console.log(data);
                            set_seqsum(
                                {
                                    pageNo:data.result.pageNo,
                                    pageSize:data.result.pageSize
                                }
                            );//设置这一页的pageNO 和pageSize

                            create_page({
                                    url:"questionAnswerManageController/searchQuestion",
                                    temp:"getColumnTableData_a_q_l",
                                    contain:"#ColumnTableData_comment_a_q_l",
                                    data:data,
                                    method:"post",
                                    add_data:{content:$(".rep_search_real_s").val(),isShow:$("#select_d_p").val()},
                                    prePageSize:data.result.pageSize,
                                    prepageNo:data.result.pageNo
                            })//生成分页

                            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                                templateId: "getColumnTableData_a_q_l",
                                container: $("#ColumnTableData_comment_a_q_l"),
                                data: data,
                                callback:function(){
                                    click_all_change();
                                }
                            })
                            first_or_not=2;
                        })
                        .fail(function(){
                            console.log("fail");
                        })
                }
            }
        })
    })
    var url,method,data;
    sessionStorage.setItem("this_page_click_num","1");
    $("#mainContainer").on("click",".rep_search",function(){
        if($(".rep_search_real_s").val()==""&&$("#select_d_p").val()==""){
            clickChange_aq=1
            url="questionAnswerManageController/showAllQuestion";
            method="get";
            data={pageSize: 10, pageNo: sessionStorage.getItem("this_page_click_num")};
        }else{
            clickChange_aq=2;
            url="questionAnswerManageController/searchQuestion";
            method="POST";
            data={pageSize: 10, pageNo:1,content:$(".rep_search_real_s").val(),isShow:$("#select_d_p").val()};
        }
        $.ajax({
            url: url,
            method: method,
            data: data
        })
        .done(function(data){
            //console.log(url);
            sessionStorage.setItem("this_page_click_num","1");
            set_seqsum(
                {
                    pageNo:data.result.pageNo,
                    pageSize:data.result.pageSize
                }
            );//设置这一页的pageNO 和pageSize
            create_page({
                url:url,
                temp:"getColumnTableData_a_q_l",
                contain:"#ColumnTableData_comment_a_q_l",
                data:data,
                method:method,
                add_data:{content:$(".rep_search_real_s").val(),isShow:$("#select_d_p").val()},
                prePageSize:data.result.pageSize,
                prepageNo:data.result.pageNo
            })//生成分页
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getColumnTableData_a_q_l",
                container: $("#ColumnTableData_comment_a_q_l"),
                data: data,
                callback:function(){
                }
            })
        })
        .fail(function(){
            console.log("fail");
        })
    })
    mccmsa.ajax({
        url: "questionAnswerManageController/showAllQuestion",
        method: "get",
        data: {pageSize: 10, pageNo: sessionStorage.getItem("this_page_click_num")},
        success: function (data){
            console.log("data_+_+_+"+data)
            set_seqsum(
                {
                    pageNo:data.result.pageNo,
                    pageSize:data.result.pageSize
                }
            );//设置这一页的pageNO 和pageSize

            create_page({
                url:"questionAnswerManageController/showAllQuestion",
                temp:"getColumnTableData_a_q_l",
                contain:"#ColumnTableData_comment_a_q_l",
                data:data,
                method:"get",
                prePageSize:data.result.pageSize,
                prepageNo:data.result.pageNo
            })//生成分页

            //console.log(data);
            mccmsa.getHtmlFromLocalTemplate({   //将数据打包到模版丢进容器
                templateId: "getColumnTableData_a_q_l",
                container: $("#ColumnTableData_comment_a_q_l"),
                data: data,
                callback:function(){
                    $(".change_show").on("click",function(){
                        console.log("click2");
                        var this_is=$(this).attr("data-this-id");
                        var status=$(this).attr("data-status");
                        mccmsa.ajax({
                            url: "questionAnswerManageController/showOrHide",
                            method: "get",
                            data: {questionAnswerId:this_is, isShow:status},
                            success: function (data){
                                //console.log(data);
                                //console.log(data);
                                mccmsa.hashChange();
                                //count=$(".sequence").eq(0).html();//序号序号QAQ
                            }
                        })
                    })
                    //console.log(data);
                }
            })
        }
    })
    //改变是否显示

}